import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_shop_z/pages/cart_page/bloc/cart_bloc.dart';
import 'package:flutter_shop_z/pages/category_page/bloc/category_bloc.dart';
import 'package:flutter_shop_z/pages/category_page/bloc/category_id_bloc.dart';
import 'package:flutter_shop_z/pages/category_page/bloc/category_sub_bloc.dart';
import 'package:flutter_shop_z/pages/index_page.dart';
import 'package:flutter_shop_z/pages/index_page/bloc/index_count_bloc.dart';

void main() {
  // var counter = Counter();
  // var childCategory = ChildCategory();
  // var providers = Providers();
  // providers
  //   ..provide(Provider<Counter>.value(counter))
  //   ..provide(Provider<ChildCategory>.value(childCategory));
  // runApp(ProviderNode(child: MyApp(), providers: providers));
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    //路由配置
    // final router = Router();
    // Routes.configureRoutes(router);
    // Application.router = router;

    return MultiBlocProvider(
        providers: [
          BlocProvider<CategoryBloc>(
            create: (BuildContext context) => CategoryBloc(),
          ),
          BlocProvider<CategorySubBloc>(
            create: (BuildContext context) => CategorySubBloc(),
          ),
          BlocProvider<CartBloc>(
            create: (BuildContext context) => CartBloc(),
          ),
          BlocProvider<IndexCountBloc>(
            create: (BuildContext context) => IndexCountBloc(),
          ),
          BlocProvider<CategoryIdBloc>(
            create: (BuildContext context) => CategoryIdBloc(),
          ),
        ],
        child: Container(
          child: MaterialApp(
            title: "百姓生活+",
            debugShowCheckedModeBanner: false,
            //路由
            // onGenerateRoute: Application.router.generator,
            theme: ThemeData(primaryColor: Colors.purple),
            home: IndexPage(),
          ),
        ));
  }
}
